{% assign image = page.image %}

{% unless image %}
  {% if page.tag %}
    {% assign tag = site.data.tags[page.tag] %}
    {% assign image = tag.image %}
  {% else %}
    {% if page.tags.size > 0 %}
      {% assign tag_name = page.tags[0] %}
      {% assign tag = site.data.tags[tag_name] %}
      {% assign image = tag.image %}
    {% endif %}
  {% endif %}
{% endunless %}

{% unless image %}
  {% assign image = site.image %}
{% endunless %}

<div id="_backdrop"></div>
<a id="_menu" href="#_sidebar">☰</a>

<aside id="_sidebar" class="sidebar" {% if image %}style="background-image:url('{{site.cdn}}{{image}}');"{% endif %}>
  <div class="container sidebar-sticky">
    <div class="sidebar-about">
      <h1><img src="{{site.cdn}}/public/images/logo-white-comeRound.png" alt="{{site.title}}"></h1>
      {{site.description | markdownify}}
    </div>

    <nav class="sidebar-nav">
      <div class="sidebar-nav-item"><a class="{% if page.url == '/' %}active{% endif %}" href="{{site.baseurl}}/">主页</a></div>
      {% comment %}
        The code below dynamically generates a sidebar nav of pages with
        `layout: page` in the front-matter. See readme for usage.
      {% endcomment %}

      {% assign pages_list = site.pages | sort: "sequence" %}
      {% for node in pages_list %}
        {% if node.title != null %}
          {% if node.layout == "page" %}
          <div class="sidebar-nav-item"><a class="{% if page.url == node.url %}active{% endif %}" href="{{node.url | prepend:site.baseurl}}">{{node.title}}</a></div>
          {% endif %}
        {% endif %}
      {% endfor %}

      <!-- <div class="sidebar-nav-item"><a href="/says.html">留言</a></div> -->

      {% comment %}
        Add GitHub talk page link at last.
      {% endcomment %}
    </nav>

    <div class="sidebar-social">
      {% if site.author.github %}
        <a href="https://github.com/{{site.author.github}}"><span class="iconfont icon-git"></span></a>
      {% endif %}

      {% if site.author.gitee %}
        <a href="https://gitee.com/{{site.author.gitee}}"><span class="iconfont icon-logo_gitee_icon"></span></a>
      {% endif %}

      {% if site.author.linkedin %}
        <a href="https://cn.linkedin.com/in/{{site.author.linkedin}}"><span class="iconfont icon-in"></span></a>
      {% endif %}

      {% if site.author.facebook %}
        <a href="https://www.facebook.com/{{site.author.facebook}}"><span class="iconfont icon-tian7_facebook"></span></a>
      {% endif %}

      {% if site.author.aliyun %}
        <a href="https://code.aliyun.com/u/{{site.author.aliyun}}"><span class="iconfont icon-aliyun"></span></a>
      {% endif %}

      <a href="{{site.baseurl}}/doc/atom.xml"><span class="iconfont icon-atom"></span></a>

      <span id="_dark-mode"><span class="iconfont icon-banyuan"></span></span>

    </div>
  </div>
</aside>
